#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <sys/wait.h>

int main(){
	char buf[64];
	FILE* file=fopen("./t.txt","r");
	size_t byte=fread(buf,sizeof(buf[1]),sizeof(buf),file);
	printf("<pid>=%d\n",getpid());
	write(1,buf,strlen(buf));
	if(byte==-1){
		perror("fread");
		exit(1);
	}
	pid_t pid=fork();
	if(pid==0){
		memset(buf,0,sizeof(buf));
		byte=fread(buf,1,sizeof(buf),file);
		printf("\n<pid>=%d\n",getpid());
		write(1,buf,strlen(buf));
		printf("byte=%ld\n",byte);	
		printf("dsadas");
		sleep(1);
		printf("\n");
		_exit(0);
	}else{
		wait(NULL);
		fclose(file);
	}	
	return 0;
}
